<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class UserInsertRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    //验证规则
    public function rules()
    {
        return [
            'uname'=>'required|regex:/\w{6,18}/',
            'upwd'=>'required|regex:/\w{6,18}/',
            'tel'=>'required|regex:/\w{11}/',
            'email'=>'required|email'
        ];
    }
    //返回错误信息
    public function messages()
    {
        return [
            'uname.required' => '用户名不能为空',
            'upwd.required'  => '密码不能为空',
            'tel.required'  => '电话不能为空',
            'email.required'  => '邮箱不能为空',
            'uname.regex'  => '用户名不符合规则',
            'upwd.regex'  => '密码不符合规则',
            'tel.regex'  => '电话不符合规则',
            'email.email'  => '邮箱不符合规则',
        ];
    }
}
